package com.jiangjiang.eshop.inventory.updater;

import com.jiangjiang.eshop.common.help.DateHelper;
import com.jiangjiang.eshop.inventory.domain.GoodsStockEntity;
import com.jiangjiang.eshop.inventory.service.InventoryGoodsStockService;
import com.jiangjiang.eshop.wms.dto.PurchaseInputOrderItemDTO;

import java.util.List;
import java.util.Map;

/**
 * @Author Jianghaowen
 * @Date 2021/6/7
 * @Description: TODO
 * @Version V1.0
 **/
public class PurchaseInputStockUpdater extends AbstractStockUpdater {

    /**
     * 采购入库单条目DTO集合
     */
    private Map<Long, PurchaseInputOrderItemDTO> itemDTOMap;

    /**
     * 构造方法
     * @param goodsStockService
     * @param goodsStockEntities
     * @param dateHelper
     * @param itemDTOMap
     */
    public PurchaseInputStockUpdater(InventoryGoodsStockService goodsStockService,
                                     List<GoodsStockEntity> goodsStockEntities,
                                     DateHelper dateHelper,
                                     Map<Long, PurchaseInputOrderItemDTO> itemDTOMap) {
        super(goodsStockService, goodsStockEntities, dateHelper);
        this.itemDTOMap = itemDTOMap;
    }

    @Override
    protected void updateSaleStockQuantity()  {
        for (GoodsStockEntity entity : goodsStockEntities) {
            PurchaseInputOrderItemDTO dto = itemDTOMap.get(entity.getGoodsSkuId());
            entity.setSaleStockQuantity(entity.getSaleStockQuantity() + dto.getArrivalCount());
        }
    }

    @Override
    protected void updateLockStockQuantity() throws Exception {

    }

    @Override
    protected void updateSoldStockQuantity() throws Exception {

    }
}
